package com.junmiao.A;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

public class TestComparator {
	public static void main(String[] args)
	{
		StockA a = new StockA();
		a.setStock_name("a");
		a.setStock_no("1");
		a.setOrg_share("5.45");
		
		StockA b = new StockA();
		b.setStock_name("b");
		b.setStock_no("2");
		b.setOrg_share("1.45");
		
		StockA c = new StockA();
		c.setStock_name("c");
		c.setStock_no("3");
		c.setOrg_share("2.45");
	
		ArrayList<StockA> al = new ArrayList();
		al.add(a);
		al.add(b);
		al.add(c);
		
		Collections.sort(al,new OrgShareComparator());
		
		Iterator<StockA> it = al.iterator();
		
		while(it.hasNext())
		{
			StockA ab = it.next();
			
			System.out.println("my stock  "+ ab.getStock_name() + " " + ab.getOrg_share());
		}
	}
}
